package com.smartstate.dataManagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartstate.dataManagement.entity.Equipment;
import com.smartstate.dataManagement.entity.EquipmentConfiguration;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface EquipmentConfigMapper extends BaseMapper<EquipmentConfiguration> {
    @Select("SELECT tags FROM `equipmentconfiguration` WHERE `deviceId` = #{deviceId} ")
    String selectTages(String deviceId);

    @Select("SELECT * FROM `equipmentconfiguration` WHERE `deviceId` = #{deviceId} ")
    EquipmentConfiguration selectOne(String deviceId);

    /**
     * 根据设备类型查询该类型的所有设备Id
     *
     * @param deviceType
     * @return
     */
    @Select("SELECT deviceId FROM `equipment` WHERE `type` = #{deviceType} ")
    List<String> findIdsByType(Integer deviceType);

    /**
     * 根据设备Id删除
     *
     * @param deviceId
     */
    @Delete("delete from `equipmentconfiguration` where deviceId=#{deviceId} ")
    void deleteByDeviceId(String deviceId);

    @Select("SELECT deviceId FROM `equipmentconfiguration` WHERE `way` = #{way} ")
    List<String> findAllIsWay(String way);
}
